On Exception Event
Emitted whenever the SDK encounters an internal error or unhandled exception during operation. Use this to catch and log unexpected problems.
-
Purpose: Surface SDK-level errors so you can monitor stability, log diagnostics, and optionally provide fallback UI or retry logic.
-
Functionality: The handler receives an
ErrorModel
(shape may vary) containing:message
(string) – Human-readable error description.code
(string or number, optional) – Error code if provided.details
(object, optional) – Additional context such as stack trace, payload data, or API response.
-
Usage:
- Log the error to your remote monitoring service (e.g. Sentry, Bugsnag).
- Notify users if it affects UX—show an alert or toast.
- Fallback – implement retry, graceful degradation, or navigate to an error screen.
-
Example:
import { ErrorModel } from '@one37id/mobile-js-sdk';
import { monitoring } from '../services/monitoring';
import { Alert } from 'react-native';
const handlers: EventHandlers = {
onException: async (model: ErrorModel) => {
console.error(
`Exception event received: ${JSON.stringify(model, null, 2)}`
);
// 1) send to monitoring
monitoring.captureException(model);
// 2) show user alert
Alert.alert(
'Unexpected error',
'Something went wrong. Please try again later.'
);
// 3) optional retry logic...
},
};